import { graphic } from 'echarts'

export interface IParams {
  ledendData: [string, string, string]
  xData: string[]
  yData1: number[]
  yData2: number[]
  yData3: number[]
}
export const getBottomBarCompareOptions: any = (params: IParams) => {
  const option = {
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: params.ledendData,
      textStyle: {
        color: '#fff'
      }
    },
    // toolbox: {
    //   show: true,
    //   feature: {
    //     dataView: { show: true, readOnly: false },
    //     magicType: { show: true, type: ['line', 'bar'] },
    //     restore: { show: true },
    //     saveAsImage: { show: true }
    //   }
    // },
    calculable: true,
    xAxis: [
      {
        type: 'category',
        // prettier-ignore
        data: params.xData
      }
    ],
    yAxis: [
      {
        type: 'value'
      }
    ],
    series: [
      {
        name: params.ledendData[0],
        type: 'bar',
        data: params.yData1,
        barMaxWidth: '10px',
        itemStyle: {
          borderRadius: [5, 5, 0, 0],
          color: new graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(56, 134, 255, 1)' },
            { offset: 1, color: 'rgba(56, 134, 255, 0)' }
          ])
        }
      },
      {
        name: params.ledendData[1],
        type: 'bar',
        data: params.yData2,
        barMaxWidth: '10px',
        itemStyle: {
          borderRadius: [5, 5, 0, 0],
          color: new graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(122, 97, 255, 1)' },
            { offset: 1, color: 'rgba(122, 97, 255, 0)' }
          ])
        }
      },
      {
        name: params.ledendData[2],
        type: 'bar',
        data: params.yData3,
        barMaxWidth: '10px',
        itemStyle: {
          borderRadius: [5, 5, 0, 0],
          color: new graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(108, 236, 166, 1)' },
            { offset: 1, color: 'rgba(108, 236, 166, 0)' }
          ])
        }
      }
    ]
  } 
  return option 
}